﻿using AutoMapper;
using B.S.BasicData.Api.Read.Application.Command.User;
using B.S.BasicData.Domian.Entities.Account;
using B.S.BasicData.ErrorCode;
using B.S.BasicData.Infrastructure.Interface;
using MediatR;

namespace B.S.BasicData.Api.Read.Application.Handler.User
{
    public class XianHandler : IRequestHandler<XianCommand, ApiResult<List<XianModel>>>
    {
        private readonly IBaseRepository<XianModel> ShiRepo;

        public XianHandler(IBaseRepository<XianModel> ShiRepo)
        {
            this.ShiRepo = ShiRepo;
        }
        public Task<ApiResult<List<XianModel>>> Handle(XianCommand request, CancellationToken cancellationToken)
        {
            var res = new ApiResult<List<XianModel>>();
            var shi = ShiRepo.GetAll().Where(x => x.xiangid == request.Shiid);
            res.Message = "县绑定成功";
            res.Code = ApiEnum.Ok;
            res.Data = shi.ToList();
            return Task.FromResult(res);
        }
    }
}
